(function () {
    "use strict";

    angular.module('core').factory('bandeiraCartaoService', factory);
    factory.$inject = ['$http', '$q'];

    function factory($http, $q) {
        return {
            getAll: function (args) {
                var deferred = $q.defer();
                $http.post('/bandeiracartao/getall', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            count: function (args) {
                var deferred = $q.defer();
                $http.post('/bandeiracartao/count', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            save: function (item) {
                var deferred = $q.defer();
                $http.post('/bandeiracartao/save', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            prepareNewItem: function (item) {
                var deferred = $q.defer();
                $http.post('/bandeiracartao/PrepareNewItem', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            delete: function (id) {
                var deferred = $q.defer();
                $http.post('/bandeiracartao/delete', id)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            get: function (id) {
                var deferred = $q.defer();
                $http.post('/bandeiracartao/get', id)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            }
        };
    }

})();


